home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gfxfx / fastmath.pas < prev    next >
Pascal/Delphi Source File  |  1994-06-22  |  807b  |  34 lines

  1.  
  2. unit fastmath;
  3. { approximatly-20%-faster-sin-cos-and-other-giometrical-stuff unit }
  4. { made by Bas van Gaalen, Holland, PD }
  5. { uh, not finished... }
  6.  
  7. interface
  8.  
  9. const divd = 1024;
  10.  
  11. { input: 0 <= arc <= 359, output: -divs <= sinus(arc) <= divd }
  12. function sinus(_arc : word) : integer;
  13.  
  14. { input: 0 <= arc <= 359, output: -divs <= cosin(arc) <= divd }
  15. function cosin(_arc : word) : integer;
  16.  
  17. implementation
  18.  
  19. type stype = array[0..359] of integer;
  20. var stab : stype;
  21.  
  22. procedure calcsin(var st : stype); var i : word; begin
  23.   for i := 0 to 359 do st[i] := round(sin(2*pi*i/360)*divd); end;
  24.  
  25. function sinus(_arc : word) : integer; begin
  26.   sinus := stab[_arc]; end;
  27.  
  28. function cosin(_arc : word) : integer; begin
  29.   cosin := stab[(_arc+90) mod 360]; end;
  30.  
  31. begin
  32.   calcsin(stab);
  33. end.
  34.